﻿$(document).ready(function () {
    $('.datetimepicker, #datetimepicker2, #datetimepicker3').datetimepicker({
        language: 'en',
        pick12HourFormat: true
    });
    $("#fr-salesreport").submit(function () {
        var serializedForm = $(this).serialize();
        App.blockUI($('.row1'), false);
        $.ajax({
            type: 'POST',
            url: '/reports/SearchSaleBenchMarks',
            cache: false,
            data: serializedForm,
            success: function (data) {
                $('#salebenchmark').html(data);
                App.unblockUI($('.row1'));

            },
            error: function () {
                alert('search fail!');
                App.unblockUI($('.row1'));
            }
        });
        return false;
    });
    $("#fr-orderperdays").submit(function () {
        var serializedForm = $(this).serialize();
        App.blockUI($('.row2'), false);
        $.ajax({
            type: 'POST',
            url: '/reports/SearchOrderPerDays',
            cache: false,
            data: serializedForm,
            success: function (data) {
                $('#orderperdays').html(data);
                App.unblockUI($('.row2'));

            },
            error: function () {
                alert('search fail!');
                App.unblockUI($('.row2'));
            }
        });
        return false;
    });
    $("#fr-orderperdays").submit(function () {
        var serializedForm = $(this).serialize();
        App.blockUI($('.row2'), false);
        $.ajax({
            type: 'POST',
            url: '/reports/SearchOrderRefund',
            cache: false,
            data: serializedForm,
            success: function (data) {
                $('#orderrefundperdays').html(data);
                App.unblockUI($('.row2'));
                $("#border").show();
            },
            error: function () {
                alert('search fail!');
                App.unblockUI($('.row2'));
            }
        });
        return false;
    });
    $("#fr-dailyreport").submit(function () {
            var tab = $("#storeid").val();
            var serializedForm = $(this).serialize();
            App.blockUI($('body'), false);
            $.ajax({
                type: 'POST',
                url: '/reports/ReturnDailyWebStats',
                data: serializedForm,
                success: function (data) {
                    $('#tab-' + tab).html(data);
                    App.unblockUI($('body'));
                },
                error: function () {
                    alert('error');
                    App.unblockUI($('body'));
                }
            });
            return false;
        });
});